package com.kye.express.business.invoice_online;

import android.content.Context;
import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;

import com.kye.express.R;
import com.kye.express.business.base.BaseToolbarActivity;
import com.kye.express.databinding.ActivityInvoiceinfoBinding;
import com.kye.model.bean.invoice_online.GeneratedInvoiceDataResultBean;

import java.util.ArrayList;

public class InvoiceInfoActivity extends BaseToolbarActivity {
    private static final String ARG_WAYBILLS = "waybills";
    private static final String ARG_PRICE = "price";

    protected ActivityInvoiceinfoBinding mDataBinding;
    private String[] titles = null;
    protected InvoiceInfoPageAdapter mPageAdapter;
    private ArrayList<GeneratedInvoiceDataResultBean> mCurrentSelectedWaybillList = new ArrayList<>();
    private double mTotalPrice = 0;

    public static void startActivity(Context context, ArrayList<GeneratedInvoiceDataResultBean> generatedInvoiceDataResultBeans, double totalPrice) {
        Intent intent = new Intent(context, InvoiceInfoActivity.class);
        intent.putExtra(ARG_WAYBILLS, generatedInvoiceDataResultBeans);
        intent.putExtra(ARG_PRICE, totalPrice);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mDataBinding = DataBindingUtil.setContentView(this, R.layout.activity_invoiceinfo);
        setUpToolbar((Toolbar) findViewById(R.id.toolbar));
        setTitle(getString(R.string.invoice_info));
        initViews();
        initEvents();
    }


    private void initViews() {
        mCurrentSelectedWaybillList = (ArrayList<GeneratedInvoiceDataResultBean>) getIntent().getSerializableExtra(ARG_WAYBILLS);
        mTotalPrice = getIntent().getDoubleExtra(ARG_PRICE, 0);
        titles = getResources().getStringArray(R.array.invoice_info_tab_array);
        mPageAdapter = new InvoiceInfoPageAdapter(getSupportFragmentManager(),mCurrentSelectedWaybillList,mTotalPrice);
        mDataBinding.viewpage.setOffscreenPageLimit(titles.length);
        mDataBinding.viewpage.setAdapter(mPageAdapter);
        mDataBinding.tabLayout.setViewPager(mDataBinding.viewpage, titles);
        mDataBinding.viewpage.setCurrentItem(0);
    }

    private void initEvents() {

    }
}
